package com.jinbo.footmessage;

import android.app.ProgressDialog;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Toast;

import com.jinbo.footmessage.utils.ActivitiesHelper;

public class BaseActivity extends AppCompatActivity {
    private ProgressDialog mProgressDialog;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

       /* 把当前的类加入到ActivitiesHelper的单例中，
       ActivitiesHelper用来管理App中的Activity的类，
       ActivitiesHelper提供增加、删掉、获取最顶的Activity、
       关闭指定的Activity等方法*/
        ActivitiesHelper.getInstance().addActivity(this);
    }
    public  void show(CharSequence text) {
        Toast.makeText(this, text, Toast.LENGTH_SHORT).show();
    }

   @Override
    public void startActivity(Intent intent) {

       super.startActivity(intent);
       overridePendingTransition(R.anim.in_from_right, R.anim.amin_stay);
       // overridePendingTransition(android.R.anim.slide_out_right,0);

    }

    @Override
    public void startActivityForResult(Intent intent, int requestCode)
    {
        super.startActivityForResult(intent, requestCode);
        overridePendingTransition(R.anim.in_from_right, R.anim.amin_stay);
    }
    /**
     * 显示进度框
     */
    public void showProgressDialog(String title){
        mProgressDialog = new ProgressDialog(this);
        mProgressDialog.setMessage(title);
        mProgressDialog.show();
    }

    public void dismissProgressDialog(){
        if (mProgressDialog != null) {
            mProgressDialog.dismiss();
        }
    }
/*    @Override
    public void onBackPressed() {
        super.onBackPressed();
        overridePendingTransition(0, R.anim.out_from_right);
    }*/


    @Override
    public void finish() {
        super.finish();
        overridePendingTransition(R.anim.amin_stay, R.anim.out_from_right);
    }
    @Override
    protected void onDestroy() {
        super.onDestroy();
        ActivitiesHelper.getInstance().removeActivity(this);
    }
}
